package luj.tool.jnproxyan.proxy.network.socks.cmd.connect;

import io.netty.buffer.ByteBuf;
import luj.net.api.client.NetConnection;
import luj.net.api.server.FrameDataReceiver;

/**
 * @see C2pReceiverV2
 */
@Deprecated
final class C2pReceiver implements FrameDataReceiver {

  C2pReceiver(NetConnection p2sConn) {
    _p2sConn = p2sConn;
  }

  @Override
  public Result receive(Context ctx) throws Exception {
    ByteBuf frameBuf = ctx.getLastFrame();

    frameBuf.retain();
    _p2sConn.send(frameBuf);

    return ctx.then().nextReceiver(this);
  }

  private final NetConnection _p2sConn;
}
